export default{
    getDate(seconds,type,str){//时间戳转换时间格式：时间戳，转换类型，分割字符
	    let _str = str?str:'-'
	    let _type = type?type:1
	    let date = new Date(seconds)
	    let year = date.getFullYear()
	    let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
	    let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
	    let hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
	    let minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
	    let second = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
	    //let currentTime = year + '/' + month + '/' + day + ' ' + hour + ':' + minute + ':' + second
	    switch (_type){
	      case 1:
	        var currentTime = year + _str + month + _str + day + ' ' + hour + ':' + minute + ':' + second //年月日时分秒
	        break;
	      case 2:
	        var currentTime = year + _str + month + _str + day + ' ' + hour + ':' + minute //年月日时分
	        break;
	      case 3:
	        var currentTime = year + _str + month + _str + day //年月日
	        break;
	      case 4:
	        var currentTime = year + _str + month//年月
	        break;
		  case 5:
		    var currentTime = month + '月' + day + '日'//月日
		    break;
	    }
	    return currentTime
	},
	
}
function getDate(seconds,type,str){//时间戳转换时间格式：时间戳，转换类型，分割字符
	let _str = str?str:'-'
	let _type = type?type:1
	let date = new Date(seconds)
	let year = date.getFullYear()
	let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
	let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
	let hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
	let minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
	let second = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
	//let currentTime = year + '/' + month + '/' + day + ' ' + hour + ':' + minute + ':' + second
	switch (_type){
	  case 1:
		var currentTime = year + _str + month + _str + day + ' ' + hour + ':' + minute + ':' + second //年月日时分秒
		break;
	  case 2:
		var currentTime = year + _str + month + _str + day + ' ' + hour + ':' + minute //年月日时分
		break;
	  case 3:
		var currentTime = year + _str + month + _str + day //年月日
		break;
	  case 4:
		var currentTime = year + _str + month//年月
		break;
	  case 5:
		var currentTime = month + '月' + day + '日'//月日
		break;
	}
	return currentTime
}
//根据传入的参数名获取对应的参数值
function GetQueryStr(name){
	var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if(r!=null)return  unescape(r[2]); return null;
}

//金额验证
function isMoney(value){
	var mny = /^[0-9]*(\.[0-9]{1,2})?$/;
	return mny.test(value)
}

export {
	GetQueryStr,isMoney,getDate
}